import sys,os
sys.path.append(os.pardir)
import numpy as np
from common.functions import softmax,cross_entropy_error
from common.gradient import numerical_gradient

class SimpleNet:
    def __init__(self):
        self.W = np.array([[0.4736,0.9977,0.8467],[0.8556,0.0356,0.6942]])
    def predict(self,x):
        return np.dot(x,self.W)
    
    def loss(self,x,t):
        z =self.predict(x)
        y =softmax(z)
        loss = cross_entropy_error(y,t)

        return loss
    
x = np.array([0.6,0.9])
t = np.array([0,0,1])

net = SimpleNet()
f = lambda w:net.loss(x,t)
dw = numerical_gradient(f,net.W)
print(dw)